﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using BusinessApplication1.ServiceReference;


namespace BusinessApplication1.Views
{
    public partial class AddNewProject : ChildWindow
    {

        //private string _projectName;
        //private string _projectDescription;
        //private int _priorityIndex;
        //private DateTime _projectTimeStart;
        //private DateTime _projectTimeFinish;

        private Project _projToHandle;

        public Project ProjToHandle
        {
            get { return _projToHandle; }
            set { _projToHandle = value; }
        }

        #region Старье
        
        //public string ProjectName
        //{
        //    get { return _projectName; }
        //    set { _projectName = value; }
        //}

        //public string ProjectDescription
        //{
        //    get { return _projectDescription; }
        //    set { _projectDescription = value; }
        //}

        //public int PriorityIndex
        //{
        //    get { return _priorityIndex; }
        //    set { _priorityIndex = value; }
        //}

        //public DateTime ProjectTimeStart
        //{
        //    get { return _projectTimeStart; }
        //    set { _projectTimeStart = value; }
        //}

        //public DateTime ProjectTimeFinish
        //{
        //    get { return _projectTimeFinish; }
        //    set { _projectTimeFinish = value; }
        //}
        #endregion


        public AddNewProject()
        {
            InitializeComponent();
            _projToHandle = new Project();
            this.DataContext = ProjToHandle;
        }

        public AddNewProject(Project ChangProject)
        {
            InitializeComponent();
            _projToHandle = new Project();
            //NametextBox.Text = ChangProject.Name;
            //DescriptiontextBox.Text=ChangProject.description;
        }

        private void OKButton_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = true;

            

            ProjectDatabaseInteractionClient svc = new ServiceReference.ProjectDatabaseInteractionClient();

            svc.AddNewProjectCompleted += (_s, _e) =>
            {
                MessageBox.Show(String.Format("Добавлен проект: Название{0} \n ID: {1} \n  Описание {2} !", _e.Result.Name, _e.Result.IDProject, _e.Result.Description));
            };
            svc.AddNewProjectAsync(ProjToHandle);

            
        }

        private void CancelButton_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = false;
        }

        
    }
}

